function P=p2012(Students,Options)
s=Students(Students.proceso==2012,{'rut','region','nem','leng','mate','hria','cien','private_hs','s_bea','cae_eligible','aid_amount','reference_tuition'});
s.bea=strcmpi(s.s_bea,'BEA');
o=Options(Options.proceso==2012,{'cod','Univ','x_b_nem','x_b_psu_leng','x_b_psu_mate','x_b_psu_hria','x_b_psu_cien','max_hria_cien','valor_matricula','valor_arancel','ref'});
discounts=zeros(size(s,1),size(o,1));
becas=zeros(size(s,1),size(o,1));
stipends=zeros(size(s,1),size(o,1));

%Univ 11
oaux=o(o.Univ==11,:);
j=0;
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    weights=oaux{oaux.cod==demrecode,{'x_b_nem','x_b_psu_leng','x_b_psu_mate','x_b_psu_hria','x_b_psu_cien','max_hria_cien'}};
    s.score=0.01*(s{:,{'nem','leng','mate','hria','cien'}}*weights(1:end-1)'-min(s.hria,s.cien)*(weights(end-1)*weights(end))).*(s.nem.*s.leng.*s.mate>0).*(s.hria+s.cien>0);
    [discount,beca,stipend] = u11_2012(s.mate,s.leng,demrecode,s.score,s.region);
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 12
oaux=o(o.Univ==12,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    [discount,beca,stipend] = u12_2012(s.mate,s.leng,demrecode);
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 13
oaux=o(o.Univ==13,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    [discount,beca,stipend] = u13_2012(s.mate,s.leng,demrecode);
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 14
oaux=o(o.Univ==14,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    [discount,beca,stipend] = u14_2012(s.mate,s.leng,demrecode,s.hria,s.cien);
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 15
oaux=o(o.Univ==15,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    [discount,beca,stipend] = u15_2012();
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 16
oaux=o(o.Univ==16,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    [discount,beca,stipend] = u16_2012(s.mate,s.leng,demrecode);
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 17
oaux=o(o.Univ==17,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    [discount,beca,stipend] = u17_2012(s.mate,s.leng,demrecode);
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 18
oaux=o(o.Univ==18,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    [discount,beca,stipend] = u18_2012(s.mate,s.leng,demrecode);
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 19
oaux=o(o.Univ==19,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    weights=oaux{oaux.cod==demrecode,{'x_b_nem','x_b_psu_leng','x_b_psu_mate','x_b_psu_hria','x_b_psu_cien','max_hria_cien'}};
    s.score=0.01*(s{:,{'nem','leng','mate','hria','cien'}}*weights(1:end-1)'-min(s.hria,s.cien)*(weights(end-1)*weights(end))).*(s.nem.*s.leng.*s.mate>0).*(s.hria+s.cien>0);
    [discount,beca,stipend] = u19_2012(s.mate,s.leng,demrecode,s.hria,s.cien,s.score);
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 20
oaux=o(o.Univ==20,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    [discount,beca,stipend] = u20_2012(s.mate,s.leng,demrecode);
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 21
oaux=o(o.Univ==21,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    [discount,beca,stipend] = u21_2012(s.mate,s.leng);
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 22
oaux=o(o.Univ==22,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    [discount,beca,stipend] = u22_2012(s.mate,s.leng,demrecode);
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 23
oaux=o(o.Univ==23,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    [discount,beca,stipend] = u23_2012(s.mate,s.leng,demrecode);
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 24
oaux=o(o.Univ==24,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    [discount,beca,stipend] = u24_2012(s.mate,s.leng,demrecode);
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 25
oaux=o(o.Univ==25,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    [discount,beca,stipend] = u25_2012(s.mate,s.leng,demrecode);
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 26
oaux=o(o.Univ==26,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    [discount,beca,stipend] = u26_2012(s.mate,s.leng,demrecode);
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 27
oaux=o(o.Univ==27,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    [discount,beca,stipend] = u27_2012(s.mate,s.leng,demrecode);
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 29
oaux=o(o.Univ==29,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    [discount,beca,stipend] = u29_2012(s.mate,s.leng,demrecode);
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 30
oaux=o(o.Univ==30,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    [discount,beca,stipend] = u30_2012(s.mate,s.leng,demrecode,s.hria,s.cien);
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 32
oaux=o(o.Univ==32,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    [discount,beca,stipend] = u32_2012(s.mate,s.leng,demrecode);
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 33
oaux=o(o.Univ==33,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    [discount,beca,stipend] = u33_2012(s.mate,s.leng,demrecode);
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 34
oaux=o(o.Univ==34,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    [discount,beca,stipend] = u34_2012(s.mate,s.leng,demrecode,s.hria,s.cien,s.nem);
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 35
oaux=o(o.Univ==35,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    [discount,beca,stipend] = u35_2012(s.mate,s.leng,demrecode,s.hria,s.cien);
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 36
oaux=o(o.Univ==36,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    [discount,beca,stipend] = u36_2012(s.mate,s.leng,demrecode,s.hria,s.cien,oaux{oaux.cod==demrecode,{'valor_arancel'}},oaux{oaux.cod==demrecode,{'ref'}});
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 37
oaux=o(o.Univ==37,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    [discount,beca,stipend] = u37_2012(s.mate,s.leng,demrecode,s.hria,s.cien);
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 38
oaux=o(o.Univ==38,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    [discount,beca,stipend] = u38_2012(s.mate,s.leng,demrecode,s.hria,s.cien);
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 39
oaux=o(o.Univ==39,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    [discount,beca,stipend] = u39_2012(s.mate,s.leng,demrecode,s.hria,s.cien,s.region);
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 40
oaux=o(o.Univ==40,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    [discount,beca,stipend] = u40_2012(s.mate,s.leng,demrecode);
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 41
oaux=o(o.Univ==41,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    [discount,beca,stipend] = u41_2012(s.mate,s.leng,s.private_hs,demrecode,oaux{oaux.cod==demrecode,{'valor_arancel'}},oaux{oaux.cod==demrecode,{'ref'}});
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 42
oaux=o(o.Univ==42,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    [discount,beca,stipend] = u42_2012(s.mate,s.leng,demrecode,s.hria,s.cien);
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 43
oaux=o(o.Univ==43,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    [discount,beca,stipend] = u43_2012(s.mate,s.leng,demrecode);
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 44
oaux=o(o.Univ==44,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    [discount,beca,stipend] = u44_2012(s.mate,s.leng,s.private_hs,demrecode,oaux{oaux.cod==demrecode,{'valor_arancel'}},oaux{oaux.cod==demrecode,{'ref'}});
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

%Univ 45
oaux=o(o.Univ==45,:);
for demrecode = oaux{:,{'cod'}}'
    j=j+1;
    [discount,beca,stipend] = u45_2012(s.mate,s.leng,s.private_hs,demrecode);
    discounts(:,j)=discount; becas(:,j)=beca; stipends(:,j)=stipend;
end

P=cat(3,discounts,becas,stipends);

%hist(sum(P(:,:,1)>0)/size(Students(Students.proceso==2012,:),1))
end